package javacroft.dataccess;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Classe dérivée de gestion de la couche persistance base de données Oracle
 * @author Fabien RETIF
 * @version 1.0
 */
public class OracleProvider extends DataAccessFactory
{

    private Connection laConnexion = null;

    /**
     * Constructeur
     */
    public OracleProvider()
    {
        super("jdbc:oracle:thin:@v240.ig.polytech.univ-montp2.fr:1521:ORA10");
    }

    @Override
    public void openDataAccess () throws Exception
    {
        Class cDriverOracle=Class.forName("oracle.jdbc.driver.OracleDriver");
        Driver dDriverOracle=(java.sql.Driver)cDriverOracle.newInstance();
        DriverManager.registerDriver(dDriverOracle);
        laConnexion=DriverManager.getConnection("jdbc:oracle:thin:@v240.ig.polytech.univ-montp2.fr:1521:ORA10","fabien.retif","oracle");
    }

    @Override
    public void closeDataAccess() throws Exception
    {
        laConnexion.close();
    }

    @Override
    public List<Map> getLesDepartements()  throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom, DEREF(resp).nom AS nom_responsable, DEREF(resp).prenom AS prenom_responsable FROM Departement");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           //uneLigne.put("unNomResponsable", rs.getObject(2).toString());
          // uneLigne.put("unPrenomResponsable", rs.getObject(3).toString());
           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();
       return lesResultats;

    }

    @Override
    public List<Map> getLesAnnees(String nomDepartement)  throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT A.nom, DEREF(resp).nom AS nom_responsable, DEREF(resp).prenom AS prenom_responsable FROM Annee A WHERE REF(A) IN (SELECT column_value FROM Departement D, TABLE(D.annee_nt) WHERE D.nom = '"+nomDepartement+"')");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           //uneLigne.put("unNomResponsable", rs.getObject(2).toString());
           //uneLigne.put("unPrenomResponsable", rs.getObject(3).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesSemestres(String nomAnnee)  throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT S.numero, S.code FROM Semestre S WHERE REF(S) IN (SELECT column_value FROM Annee A, TABLE(A.semestre_nt) WHERE A.nom = '"+nomAnnee+"')");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();          
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNumero", rs.getObject(1).toString());
           uneLigne.put("unCodeApogee", rs.getObject(2).toString());
           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesUE(String codeApogee)  throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;
      
       openDataAccess();
       laRequete = laConnexion.createStatement();
        
       ResultSet rs= laRequete.executeQuery("SELECT U.nom, U.credits FROM UE U WHERE REF(U) IN (SELECT column_value FROM Semestre S, TABLE(S.ue_nt) WHERE S.code = '"+codeApogee+"')");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();
           
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           uneLigne.put("nbCredit", rs.getObject(2).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesECUE(String nomUE)  throws Exception
    {
        List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT E.nom, E.coeff, DEREF(resp).nom AS nom_responsable, DEREF(resp).prenom AS prenom_responsable FROM ECUE E WHERE REF(E) IN (SELECT column_value FROM UE U, TABLE(U.ecue_nt) WHERE U.nom = '"+nomUE+"')");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();
          
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           uneLigne.put("unCoeff", rs.getObject(2).toString());
           //uneLigne.put("unNomResponsable", rs.getObject(3).toString());
           //uneLigne.put("unPrenomResponsable", rs.getObject(4).toString());
           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesEtudiantsAnnee(String nomAnnee)  throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("(SELECT Et.nom AS nom_etud, Et.prenom AS prenom_etud, Et.toeic AS toeic, Et.ptsJury AS pj_annee, S.code AS code_sem, pj_semestre(Et.nom, Et.prenom, DEREF(U.column_value).nom) AS pj_sem, semestre_etranger(Et.nom, Et.prenom, S.code) AS etranger, DEREF(U.column_value).nom AS nom_ue, est_apdj(Et.nom, Et.prenom, DEREF(U.column_value).nom) AS apdj, DEREF(Ec.column_value).nom AS nom_ECUE, N.note, N.rattrapage FROM Etudiant Et, TABLE(Et.ue_nt) U, TABLE(DEREF(U.column_value).ecue_nt) Ec, Notation N, Semestre S, TABLE(S.ue_nt) T WHERE DEREF(N.etud).nom = Et.nom AND DEREF(N.etud).prenom = Et.prenom AND DEREF(N.matiere).nom = DEREF(Ec.column_value).nom AND T.column_value IN (SELECT T.column_value FROM Semestre S2, TABLE(S2.ue_nt) T WHERE DEREF(T.column_value).nom = DEREF(U.column_value).nom) AND DEREF(Et.annee).nom = '"+nomAnnee+"' ) UNION ( SELECT Et.nom AS nom_etud, Et.prenom AS prenom_etud, Et.toeic AS toeic, Et.ptsJury AS pj_annee, S.code AS code_sem, pj_semestre(Et.nom, Et.prenom, DEREF(U.column_value).nom) AS pj_sem, semestre_etranger(Et.nom, Et.prenom, S.code) AS etranger, DEREF(U.column_value).nom AS nom_ue, est_apdj(Et.nom, Et.prenom, DEREF(U.column_value).nom) AS apdj, DEREF(Ec.column_value).nom AS nom_ECUE, -1, 0 FROM Etudiant Et, TABLE(Et.ue_nt) U, TABLE(DEREF(U.column_value).ecue_nt) Ec,  Semestre S, TABLE(S.ue_nt) T WHERE T.column_value IN (SELECT T.column_value FROM Semestre S2, TABLE(S2.ue_nt) T WHERE DEREF(T.column_value).nom = DEREF(U.column_value).nom) AND DEREF(Et.annee).nom = '"+nomAnnee+"' AND Et.nom NOT IN (SELECT DEREF(etud).nom FROM Notation WHERE DEREF(matiere).nom = DEREF(Ec.column_value).nom)) ORDER BY nom_etud, prenom_etud, code_sem");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();
          
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           uneLigne.put("unPrenom", rs.getObject(2).toString());
           uneLigne.put("scoreTOEIC", rs.getObject(3).toString());
           uneLigne.put("pointJuryAnnee", rs.getObject(4).toString());
           uneLigne.put("codeSemestre", rs.getObject(5).toString());
           uneLigne.put("pointJurySemestre", rs.getObject(6).toString());
           uneLigne.put("estSemestreEtranger", rs.getObject(7).toString());
           uneLigne.put("nomUE", rs.getObject(8).toString());
           uneLigne.put("apdjUE", rs.getObject(9).toString());
           uneLigne.put("nomECUE", rs.getObject(10).toString());
           uneLigne.put("saNote", rs.getObject(11).toString());
           uneLigne.put("estRattrapage", rs.getObject(12).toString());
           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesMoyennesEtranger(String nom, String prenom,String codeSemestre) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT moyenne FROM Etranger WHERE DEREF(etud).nom = '"+nom+"' AND DEREF(etud).prenom = '"+prenom+"' and DEREF(sem).code = '"+codeSemestre+"'");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("moyenneSemestre", rs.getObject(1).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getInfosEnseignant(String login, String password) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT DISTINCT E.nom, E.prenom, D.nom FROM Enseignant E, Departement D, Annee A, Semestre S, UE U, ECUE EC WHERE E.login = '"+login+"' AND E.password = '"+password+"' AND ( (DEREF(D.resp).nom = E.nom AND DEREF(D.resp).prenom = E.prenom) OR (DEREF(A.resp).nom = E.nom AND DEREF(A.resp).prenom = E.prenom AND REF(A) IN (SELECT column_value FROM TABLE(D.annee_nt))) OR (DEREF(U.resp).nom = E.nom AND DEREF(U.resp).prenom = E.prenom AND REF(U) IN (SELECT column_value FROM TABLE(S.ue_nt) WHERE REF(S) IN (SELECT column_value FROM TABLE(A.semestre_nt) WHERE REF(A) IN (SELECT column_value FROM TABLE(D.annee_nt))))) OR (DEREF(EC.resp).nom = E.nom AND DEREF(EC.resp).prenom = E.prenom AND REF(EC) IN (SELECT column_value FROM TABLE(U.ecue_nt) WHERE REF(U) IN (SELECT column_value FROM TABLE(S.ue_nt) WHERE REF(S) IN (SELECT column_value FROM TABLE(A.semestre_nt) WHERE REF(A) IN (SELECT column_value FROM TABLE(D.annee_nt)))))) )");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();
           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());
           uneLigne.put("unPrenom", rs.getObject(2).toString());
           uneLigne.put("nomDepartement", rs.getObject(3).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;

     }

    @Override
    public List<Map> getLesDepartementsEnseignant(String nom, String prenom) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom FROM Departement WHERE DEREF(resp).nom = '"+nom+"' AND DEREF(resp).prenom = '"+prenom+"'");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());         

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }   

    @Override
    public List<Map> getLesAnneesEnseignant(String nom, String prenom) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom FROM Annee WHERE DEREF(resp).nom = '"+nom+"' AND DEREF(resp).prenom = '"+prenom+"'");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesUEEnseignant(String nom, String prenom) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom FROM UE WHERE DEREF(resp).nom = '"+nom+"' AND DEREF(resp).prenom = '"+prenom+"'");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public List<Map> getLesECUEEnseignant(String nom, String prenom) throws Exception
    {
       List<Map> lesResultats = new ArrayList<Map>();
       Map<String,String> uneLigne = null;
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom FROM ECUE WHERE DEREF(resp).nom = '"+nom+"' AND DEREF(resp).prenom = '"+prenom+"'");

       while(rs.next())
       {
           uneLigne = new HashMap<String,String>();

           //On ajoute couple nomAttribut/Valeur
           uneLigne.put("unNom", rs.getObject(1).toString());

           //On ajoute la ligne dans les résultats
           lesResultats.add(uneLigne);
       }

       laRequete.close();
       closeDataAccess();

       return lesResultats;
    }

    @Override
    public String existeNote(String nom, String prenom,String nomECUE) throws Exception
    {
       Statement laRequete = null;
       String res="0";

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT COUNT(*) FROM Notation WHERE DEREF(etud).nom = '"+nom+"' AND DEREF(etud).prenom = '"+prenom+"' AND DEREF(matiere).nom = '"+nomECUE+"'");

       if(rs.next())
       {
          res = rs.getObject(1).toString();
       }
       laRequete.close();
       closeDataAccess();

       return res;

    }

    @Override
    public void updateNote(String nom, String prenom,String nomECUE,String note,String estRattrapage) throws Exception
    {
       Statement laRequete = null;
       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("UPDATE Notation SET note = "+note+", rattrapage = "+estRattrapage+" WHERE DEREF(etud).nom = '"+nom+"' AND DEREF(etud).prenom = '"+prenom+"' AND DEREF(matiere).nom = '"+nomECUE+"'");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void insertNote(String nom, String prenom,String nomECUE,String note,String estRattrapage) throws Exception
    {
       Statement laRequete = null;
       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("INSERT INTO Notation VALUES ("+note+", "+estRattrapage+",(SELECT REF(E) FROM Etudiant E WHERE E.nom = '"+nom+"' AND E.prenom = '"+prenom+"'),(SELECT REF(E) FROM ECUE E WHERE E.nom = '"+nomECUE+"'))");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void deleteAllAPDJ(String nom, String prenom) throws Exception
    {
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("UPDATE Etudiant SET apdj_nt = tue_nt() WHERE nom = '"+nom+"' AND prenom = '"+prenom+"'");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void insertAPDJ(String nom, String prenom,String nomUE) throws Exception
    {
       Statement laRequete = null;
       
       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("INSERT INTO TABLE(SELECT apdj_nt FROM Etudiant WHERE nom = '"+nom+"' AND prenom = '"+prenom+"') VALUES ((SELECT REF(U) FROM UE U WHERE U.nom = '"+nomUE+"'))");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void deleteAllPointJurySemestre(String nom, String prenom) throws Exception
    {
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("DELETE FROM PointsJury WHERE DEREF(etud).nom = '"+nom+"' AND DEREF(etud).prenom = '"+prenom+"'");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void deleteAllPointJuryAnnee(String nom, String prenom) throws Exception
    {
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("UPDATE Etudiant SET ptsJury = 0 WHERE nom = '"+nom+"' AND prenom = '"+prenom+"'");
       laRequete.close();
       closeDataAccess();

    }

    @Override
    public void insertPointJuryAnnee(String nom, String prenom, String nbPoint) throws Exception
    {
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("UPDATE Etudiant SET ptsJury = "+nbPoint+" WHERE nom = '"+nom+"' AND prenom = '"+prenom+"'");

       laRequete.close();
       closeDataAccess();
    }

    @Override
    public void insertPointJurySemestre(String nom, String prenom, String codeSemestre, String nbPoint) throws Exception
    {
       Statement laRequete = null;

       openDataAccess();
       laRequete = laConnexion.createStatement();
       laRequete.execute("INSERT INTO PointsJury VALUES ("+nbPoint+", (SELECT REF(S) FROM Semestre S WHERE S.code = '"+codeSemestre+"'), (SELECT REF(E) FROM Etudiant E WHERE nom = '"+nom+"' AND prenom = '"+prenom+"'))");
       laRequete.close();
       closeDataAccess();
    }

    @Override
    public Map getAnneeUE(String nomUE) throws Exception
    {
       Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT A.nom FROM Annee A, TABLE(A.semestre_nt) WHERE column_value IN (SELECT REF(S) FROM Semestre S, TABLE(S.ue_nt) WHERE DEREF(column_value).nom = '"+nomUE+"')");

       if(rs.next())
       {
          res.put("unNom",rs.getObject(1).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }

    @Override
    public Map getAnneeECUE(String nomECUE) throws Exception
    {
       Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT A.nom FROM Annee A, TABLE(A.semestre_nt) WHERE column_value IN (SELECT REF(S) FROM Semestre S, TABLE(S.ue_nt) WHERE column_value IN (SELECT REF(U) FROM UE U, TABLE(U.ecue_nt) WHERE DEREF(column_value).nom = '"+nomECUE+"'))");

       if(rs.next())
       {
          res.put("unNom",rs.getObject(1).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }

    @Override
    public Map getLeSemestreUE(String nomUE) throws Exception
    {
       Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT S.code, S.numero FROM Semestre S, TABLE(S.ue_nt) WHERE DEREF(column_value).nom = '"+nomUE+"'");

       if(rs.next())
       {
          res.put("codeApogee",rs.getObject(1).toString());
          res.put("unNumero",rs.getObject(2).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }

    @Override
    public Map getLeSemestreECUE(String nomECUE) throws Exception
    {
        Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT S.code, S.numero FROM Semestre S, TABLE(S.ue_nt) WHERE column_value IN (SELECT REF(U) FROM UE U, TABLE(U.ecue_nt) WHERE DEREF(column_value).nom = '"+nomECUE+"')");

       if(rs.next())
       {
          res.put("codeApogee",rs.getObject(1).toString());
          res.put("unNumero",rs.getObject(2).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }

    @Override
    public Map getUEECUE(String nomECUE) throws Exception
    {
        Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom, credits FROM UE, TABLE(UE.ecue_nt) WHERE DEREF(column_value).nom = '"+nomECUE+"'");

       if(rs.next())
       {
          res.put("unNom",rs.getObject(1).toString());
          res.put("nbCredit",rs.getObject(2).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }

    @Override
    public Map getECUE(String nomECUE) throws Exception
    {
        Statement laRequete = null;
       Map res = new HashMap<String,String>();

       openDataAccess();
       laRequete = laConnexion.createStatement();
       ResultSet rs= laRequete.executeQuery("SELECT nom, coeff FROM ECUE WHERE nom = '"+nomECUE+"'");

       if(rs.next())
       {
          res.put("unNom",rs.getObject(1).toString());
          res.put("unCoeff",rs.getObject(2).toString());
       }

       laRequete.close();
       closeDataAccess();

       return res;
    }
}
